import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "@/pages/Login.vue";
import Home from "@/pages/Home.vue";
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: Login,
    beforeEnter(to,from,next){
      console.log('路由独享守卫beforeEnter');
      next();
    }
  },
  {
    path: '/home',
    component: Home
  }
]

const router = new VueRouter({
  mode: 'history',
  routes
})
router.beforeEach(function(to,from,next){
  console.log("全局前置beforeEach");
  next();
});
router.afterEach(function(to,from,next){
  console.log("全局后置afterEach");
})
router.beforeResolve(function(to,from,next){
  console.log("全局解析beforeResolve");
  next();
})

export default router
